<? defined( '_JEXEC' ) or die( 'Restricted access' );?>
<form action="index.php" method="post" name="adminForm" >
Product name
<input type="text" name="title" id="title" value="<?php echo $this->search['title'];?>" class="text_area"  title="<?php echo JText::_( 'Filter by Title' );?>"/>
&nbsp;&nbsp;
Category
<select name="category" id="category">
<option  value="" >- - - Select a category - - -</option>
<?php
	foreach ($this->catgories as $row){
		if($this->search['category']==$row->id)	echo "<option selected='selected' value='".$row->id."' >".$row->name_display."</option>";
		else echo "<option  value='".$row->id."' >".$row->name_display."</option>";
	}
?>
</select>
&nbsp;&nbsp;
Manufacturer
<select name="company" id="company">
	<option value='0'>--Select a company--</option>
	<?php
		$db =& JFactory::getDBO();
		$query = "select * from #__pr_company where published=1";
		$db->setQuery($query);
		if($rows = $db->loadObjectList()){
			foreach($rows as $row){
				if($this->search['company']==$row->id){
					echo "<option selected='selected' value='".$row->id."'>".$row->name."</option>";
				} else {
					echo "<option value='".$row->id."'>".$row->name."</option>";
				}
			}
		}
	?>
</select>
&nbsp;&nbsp;
<button onclick="this.form.submit();"><?php echo JText::_( 'Search' ); ?></button>
<br />
<div id="editcell">
	<table class="adminlist">
	<thead>
		<tr>
			<th width="2%">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->products ); ?>);" />
			</th>
			<th width="2%" align="center">
				Number
			</th>
			<th width="10%">
				Name
			</th>
			<th width="8%">
				Manufacturer
			</th>
			<th width="12%">
				Type
			</th>
			<th width="10%">
				Price
			</th>
			<th width="20%">
				Instruction
			</th>
			<th width="7%">
				Image
			</th>
			<th width="5%">
				Quantity
			</th>
			<th width="10%">Order<?php echo JHTML::_('grid.order',  $this->products); ?></th>
			<th width="5%" nowrap="nowrap">Sale-off</th>
			<th width="5%" nowrap="nowrap">Published</th>
		</tr>			
	</thead>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->products); $i < $n; $i++)
	{		$row = &$this->products[$i];
		$checked 	 = JHTML::_('grid.id',   $i, $row->id );
		$link 		 = JRoute::_( 'index.php?option=com_ecommerce&controller=products&task=edit&cid[]='. $row->id );
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $checked; ?>
			</td>
			<td align="center">
				<?php echo $row->number; ?>
			</td>
			<td align="center">
				<a href="<?php echo $link; ?>"><?php echo $row->name; ?></a>
			</td>
			<td align="center">
				<?php echo $row->company_name; ?>
			</td>
			<td align="center">
				<?php $arrType = explode(",",$row->type); 
				if(in_array(1, $arrType))  echo '<img src="../images/1.png" />&nbsp;';
				if(in_array(2, $arrType))  echo '<img src="../images/2.png" />&nbsp;';
				if(in_array(3, $arrType))  echo '<img src="../images/3.png" />&nbsp;';
				if(in_array(4, $arrType))  echo '<img src="../images/4.png" />&nbsp;';
				if(in_array(5, $arrType))  echo '<img src="../images/5.png" />&nbsp;';
				if(in_array(6, $arrType))  echo '<img src="../images/6.png" />&nbsp;';
				if(in_array(7, $arrType))  echo '<img src="../images/7.png" />&nbsp;';
				?>
			</td>
			<td align="center">
				<strong><div style="color:#CC3300"><?php echo number_format($row->price,0,".",","); ?> DKK</div></strong>
			</td>
			<td align="center">
				<?php echo $row->instruction; ?>
			</td>
			<td align="center">
				<?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$row->image."&w=100&zc=1' title='".$row->name."' alt='".$row->name ."' align='middle' />";?>
			</td>
			<td align="center">
				<?php echo $row->quantity; ?>
			</td>

			<td align="center">
				<?php $disabled = $ordering ?  '' : 'disabled="disabled"'; ?>
				<input type="text" name="order[]" size="5" value="<?php echo $row->ordering;?>" class="text_area" style="text-align: center" />
			</td>
            
			<?php if($row->promotion){ ?>
            <td width="5%" align="center" ><a href="#unPromotion" onclick="return listItemTask('cb<?php echo $i;?>','unPromotion')"><img border="0" alt="Promotion" src="images/tick.png"/></a></td>
            <?php }else{ ?>
            <td width="5%" align="center" ><a href="#Promotion" onclick="return listItemTask('cb<?php echo $i;?>','Promotion')"><img border="0" alt="unPromotion" src="images/publish_x.png"/></a></td>
            <?php } ?>
                        
            <?php if($row->published){ ?>
            <td width="5%" align="center" ><a href="#unpublishcat" onclick="return listItemTask('cb<?php echo $i;?>','unpublishcat')"><img border="0" alt="Published Cat" src="images/tick.png"/></a></td>
            <?php }else{ ?>
            <td width="5%" align="center" ><a href="#publishcat" onclick="return listItemTask('cb<?php echo $i;?>','publishcat')"><img border="0" alt="Unpublished Cat" src="images/publish_x.png"/></a></td>
            <?php } ?>
            
            </tr>
            <?php
            $k = 1 - $k;
	}
	?>
			<tr>
				<td colspan="12">
					<?php echo $this->page->getListFooter(); ?>
				</td>
			</tr>
	</table>
</div>

<input type="hidden" name="option" value="com_ecommerce" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="products" />
</form>